<%@ page language="java" pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
	<%@include file="../common/base.jsp"%>
	<meta charset="utf-8" />
	<meta name ="viewport" content ="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-cache,must-revalidate">
	<meta http-equiv="expires" content="0">
	<title>等待接驾</title>
    <link rel="stylesheet" type="text/css" href="${base}/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${base}/css/global.css?version=${version}">
    <link rel="stylesheet" type="text/css" href="${base}/css/takecar.css?version=${version}">
</head>
<body>
    <div class="container-fluid">
    	<div class="divBox driver-info">
			<%@include file="driverHtml.jsp"%>
			<p class="tip">
				${sessionScope.departTime}出发，请提前做好准备
			</p>
    	</div>
		<%@include file="startEnd.jsp"%>
    	<a class="cancelBox">
    		<img src="${base}/images/cancel.png">
    		<p class="text">取消订单</p>
    	</a>
    </div>
</body>
<script type="text/javascript" src="${base}/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/plugin/layer-v3.0.3/layer.js"></script>
<script type="text/javascript" src="${base}/js/localStorageOpt.js?version=${version}"></script>
<script type="text/javascript" src="${base}/js/utils.js?version=${version}"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {

	var $document = $(document);
	//取消订单
	$document.on('touchend', '.cancelBox', function(event){

		layer.confirm('司机已经在赶来接您的的路上了，请您在耐心等等吧', {
			area: ['95%','auto'],
			title: "取消叫车",
			btn: ['联系师傅','确定取消'] //按钮
		}, function(index){
			$('.layui-layer-btn0').prop('href', 'tel:${sessionScope.driverDto.mobile}');
		}, function(index){
			layer.close(index);
			$.post("${base}/wx/Order/getCancelTag", {}, function (result) {
				result=result.decryptRSA();
				if(result.success){
					window.location.href = '/yue/cancel'
				}else{
					alert("获取取消原因列表失败");
				}
			});
		});
	});

	//定时请求OrderDetail，获取订单详情
	setInterval(getOrderStatus,5000);
	//获取刚才派出的订单ID
	var orderUuid = "${orderUuid}";
	function getOrderStatus() {
		$.ajax({
			type: "POST",
			url: "${base}/wx/Order/info",
			dataType: "json",
			data: {orderUuid: orderUuid},
			success: function (data) {
				if (data.success) {
					if(data.data.subStatus!=200){
						changeUrl(data.data.subStatus);
					}
				}
			}
		});
	}
});
</script>
</html>